package interfaceExample;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class MouseListenerExample2 extends JPanel implements MouseListener {
	public static void main(String args[]){
		MouseListenerExample mse = new MouseListenerExample();
		
		JFrame frame = new JFrame("MouseListenr");
		frame.getContentPane().add(mse);
		frame.setVisible(true);
		frame.setSize(800, 800);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		
	}
		
	public MouseListenerExample2(){
		this.addMouseListener(this);
	}
	
	
	public void mouseClicked(MouseEvent arg0) {
		System.out.println(arg0.getX() + " " + arg0.getY()); //simply print out x and y coords of the mouse click
	}

	public void mouseEntered(MouseEvent arg0) { }
	public void mouseExited(MouseEvent arg0) { }
	public void mousePressed(MouseEvent arg0) { }
	public void mouseReleased(MouseEvent arg0) { }
}


//you can run it, now this is the EXACT SAME THING as the last one
//but here, we didnt use a new class to handle the action, isntead on line 21, we tell it that "this" will handle the action
//and we also let the main class implement MouseListener (line 9)
//and the 5 functions are now inside the MouseListenerExample2 isntead of MouseFag class.

//so the functions that interface demands are in the same class taht implements it. In this case its "this"
